﻿Public Class Validaciones

    Public Shared Sub SoloNumeros(ByRef sender As System.Object, ByRef e As System.Windows.Forms.KeyPressEventArgs) 'TextBox
        Dim Sep As Char
        If Not (Char.IsNumber(e.KeyChar) Or e.KeyChar.Equals(Sep) Or Char.IsControl(e.KeyChar)) Then
            e.Handled = True
        End If
    End Sub

    Public Shared Sub formatMoney(ByRef sender As System.Object) 'TextBox
        Dim bt As TextBox = DirectCast(sender, TextBox)
        If bt.TextLength < 1 Then
            Exit Sub
        End If
        bt.Text = Format(CType(bt.Text, Decimal), "#,##0.00")
    End Sub

    Public Shared Function camposVacios(ByRef pBase As Panel) As Boolean
        For Each ctr As Control In pBase.Controls
            If TypeOf ctr Is TextBox And ctr.Text.Length < 1 Then
                msnBox.msnExclamacion("Complete todos los campos!!!")
                Return True
                Exit Function
            End If
        Next
        Return False
    End Function

    Public Shared Function Enter(ByRef e As System.Windows.Forms.KeyEventArgs) As Boolean
        If e.KeyCode = Keys.Enter Then
            Return True
        Else
            Return False
        End If
    End Function

End Class
